//  this library.
import 'package:hktk_app/ienum/practice/ct_enum.dart';
import 'package:hktk_app/model/practice/practice_question_model.dart';
import 'package:hktk_app/util/my_util.dart';

/// 试题收藏提交内容
class UploadCollectionModel {
  // 试题id
  String? qid;

  // 大题类型
  int? qt;

  // 试题类型名称，为空时白色标准大题类型
  String? tr;

  // 章节id
  String? cid;

  // 集合类型
  CtEnum? ct;

  // 章节名称
  String? cn;

  // 题干数据冗余
  List<Stem>? st;

  // 用户答案
  dynamic as;

  // 试题签名
  String? sn;

  // 做题时间
  int? t;

  UploadCollectionModel({
    this.qid,
    this.qt,
    this.tr,
    this.cid,
    this.ct,
    this.cn,
    this.st,
    this.as,
    this.sn,
    this.t,
  });

  UploadCollectionModel.fromJson(Map<String, dynamic> json) {
    qid = json['qid'];
    qt = json["qt"];
    tr = json["tr"];
    cid = json["cid"];
    ct = json["ct"] != null ? CtEnum.getTypeEnum(json["ct"]) : null;
    if (json["st"] != null) {
      st = <Stem>[];
      json["st"].forEach((v) {
        st!.add(Stem.fromJson(v));
      });
    }
    as = json['as'];
    sn = json["sn"];
    t = json['t'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['qid'] = qid;
    if (qt != null) {
      data["qt"] = qt!;
    }
    data["tr"] = tr;
    data["cid"] = cid;
    if (ct != null) {
      data["ct"] = ct!.name;
    }
    data["cn"] = cn;
    if (st != null) {
      data["st"] = st!.map((v) => v.toJson()).toList();
    }
    data["as"] = as;
    data["sn"] = sn;
    data["t"] = t;
    return data;
  }

  String getStStr() {
    return MyUtil.getStemStr(st);
  }
}
